<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('销售出库列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>出库单号：</label>
                                <input type="text" name="chukuDanhao"/>
                            </li>
                            <li>
                                <label>发货单号：</label>
                                <input type="text" name="fahuoDanhao"/>
                            </li>
                            <li>
                                <label>销售日期：</label>
                                <input type="text" class="time-input" placeholder="请选择销售日期" name="chukuDate"/>
                            </li>
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="xiangmuName"/>
                            </li>
                            <li>
                                <label>业务员：</label>
                                <input type="text" name="xiangmuMen"/>
                            </li>
                            <li>
                                <label>发货人：</label>
                                <input type="text" name="fahuoRen"/>
                            </li>
                            <li>
                                <label>收货地址：</label>
                                <input type="text" name="shouhuoDizhi"/>
                            </li>
                            <li>
                                <label>门扇名称：</label>
                                <input type="text" name="goodNameMen" list="goodsid"/>
                                <datalist id="goodsid" th:with="type=${@shangpinxinxiMapper.selectShangPinName()}">
                                    <option  th:each="lists : ${type}"
                                             th:text="${lists.getShangpinName()+' | '+lists.getKaiXiang()}"
                                             th:value="${lists.getShangpinName()}">
                                    </option>
                                </datalist>
                            </li>
                            <li>
                                <label>门扇宽：</label>
                                <input type="text" name="menshanKuan"/>
                            </li>
                            <li>
                                <label>门扇高：</label>
                                <input type="text" name="menshanGao"/>
                            </li>
                            <li>
                                <label>开向：</label>
                                <select name="KaiXiang"
                                        th:with="type=${@shangpinxinxiMapper.selectKaixiang()}" required>
                                    <option value="">所有</option>
                                    <option th:each="lists : ${type}"
                                            th:text="${lists}"
                                            th:value="${lists}"
                                    ></option>
                                </select>
                            </li>
<!--                            <li>-->
<!--                                <label>门框名称：</label>-->
<!--                                <input type="text" name="goodNameKuang"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                            <label>门框宽：</label>-->
<!--                            <input type="text" name="kuangKuan"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>门框高：</label>-->
<!--                                <input type="text" name="kuangGao"/>-->
<!--                            </li>-->
                            <li>
                                <label>防火锁数：</label>
                                <input type="text" name="shuliang1"/>
                            </li>
                            <li>
                                <label>闭门器数：</label>
                                <input type="text" name="shuliang2"/>
                            </li>
                            <li>
                                <label>拉爆盖数：</label>
                                <input type="text" name="shuliang3"/>
                            </li>
<!--                            <li>-->
<!--                                <label>产品备注：</label>-->
<!--                                <input type="text" name="beizhu1"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
<div hidden id="qx" th:value="${session.QuanXian}"></div>
            <div class="btn-group-sm" id="toolbar" role="group">
                <a th:unless="${session.QuanXian eq '6'}" class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="xiaoshouchuku:chukuTest:add">
                    <i class="fa fa-plus"></i> 添加发货通知单
                </a>
<!--                <div hidden th:value="${session.QuanXian}" id="quanxian"></div>th:if="${session.QuanXian eq '6'}"-->
                <a  class="btn btn-primary" onclick="f()">
                    <i class="fa fa-edit"></i> 扫码录入
                </a>
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="xiaoshouchuku:chukuTest:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="xiaoshouchuku:chukuTest:export">-->
<!--                    <i class="fa fa-download"></i> 导出所有-->
<!--                </a>-->
<!--                    <a class="btn btn-label">-->
<!--                        <div id="id2toggle" class="fa fa-toggle-off text-info fa-3x" onclick="inStart()">-->
<!--                            <i class="fa" style="font-size: 45%;vertical-align:45%;">扫码枪录入</i>-->
<!--                            <textarea id="msg2saoma" oninput="check2input4piliang()" style="height: 0;width: 0;border: 0;padding: unset"></textarea>-->
<!--                        </div>-->
<!--                    </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('xiaoshouchuku:chukuTest:edit')}]];
        var removeFlag = [[${@permission.hasPermi('xiaoshouchuku:chukuTest:remove')}]];
        var prefix = ctx + "xiaoshouchuku/chukuTest";

        // document.onmousemove = mouseMove;
        // var oldx = 0,oldy = 0;
        // function mouseMove(event) {
        //     if(document.getElementById("id2toggle").className ==="fa fa-toggle-on text-info fa-3x"){
        //         var e = event || window.event;
        //         var scrollx = document.documentElement.scrollLeft || document.body.scrollTop;
        //         var scrolly= document.documentElement.scrollTop || document.body.scrollTop;
        //         var x = e.pageX || e.clientX + scrollx;
        //         var y = e.pageY || e.clientY + scrolly;
        //         var input2saoma = document.getElementById("msg2saoma");
        //         const _select_ = document.activeElement
        //         if ((x !== oldx || y !== oldy)&&_select_ !== input2saoma){
        //             document.getElementById("msg2saoma").focus()
        //             //console.log(_select_)
        //             oldx = x;oldy=y;
        //         }
        //     }
        // }
        //
        // function inStart() {
        //
        //     var id2toggle = document.getElementById("id2toggle").className
        //     if (id2toggle === "fa fa-toggle-on text-info fa-3x"){
        //         document.getElementById("id2toggle").className= "fa fa-toggle-off text-info fa-3x"
        //         document.getElementById("msg2saoma").blur()
        //     }else {
        //         document.getElementById("id2toggle").className= "fa fa-toggle-on text-info fa-3x"
        //         document.getElementById("msg2saoma").focus()
        //     }
        // }

        function quanxian() {
            var a = 0;
            $.ajax({
                type:"POST",
                datatype: "string",
                url: "/api/QuanXian",
                data: {},
                async:false,//是否是异步请求
                success: function (result) {
                    a = result;
                }
            });
            return a;
        }

        const a = quanxian();
        if (a !== "6") {
            $(function () {
                var options = {
                    url: prefix + "/list",
                    createUrl: prefix + "/add",
                    updateUrl: prefix + "/edit/{id}",
                    removeUrl: prefix + "/remove",
                    exportUrl: prefix + "/export",
                    modalName: "销售出库",
                    columns: [
                        {
                            field: 'id',
                            title: '编号',
                            visible: false
                        },
                        {
                            title: '发货通知单',
                            formatter: function (value, row, index) {
                                var actions = [];
                                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" ' +
                                    'href="javascript:void(0)" onclick="DanJuShow(' + row.id + ')">' +
                                    '<i class="fa fa-edit"></i>出库通知单</a> ');
                                return actions.join('');
                            }
                        },
                        {
                            field: 'zhixing',
                            title: '是否已出库'
                        },
                        {
                            field: 'chukuDanhao',
                            title: '出库单号'
                        },
                        {
                            field: 'fahuoDanhao',
                            title: '发货单号'
                        },
                        {
                            field: 'chukuDate',
                            title: '销售日期'
                        },
                        {
                            field: 'xiangmuName',
                            title: '项目名称'
                        },
                        {
                            field: 'xiangmuMen',
                            title: '业务员'
                        },
                        {
                            field: 'fahuoRen',
                            title: '发货人'
                        },
                        {
                            field: 'peitao1',
                            title: '配套类型'
                        },
                        {
                            field: 'goodNameMen1',
                            title: '门扇名称'
                        },
                        {
                            field: 'kaiXiang1',
                            title: '开向'
                        },
                        {
                            field: 'men1Shuliang',
                            title: '门扇数量'
                        },
                        {
                            field: 'kuangShuliang',
                            title: '门框数量'
                        },
                        {
                            field: 'shuliang1',
                            title: '防火锁数'
                        },
                        {
                            field: 'shuliang2',
                            title: '闭门器数'
                        },
                        {
                            field: 'shuliang3',
                            title: '拉爆盖数'
                        },
                        {
                            field: 'beizhu1',
                            title: '门扇备注'
                        },
                        {
                            field: 'zhonjine',
                            title: '销售金额'
                        },
                        {
                            title: '操作',
                            align: 'center',
                            formatter: function (value, row, index) {
                                var actions = [];
                                    actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                                    actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                                return actions.join('');
                            }
                        }]
                };
                $.table.init(options);
            })
        }else {
            $(function () {
                var options = {
                    url: prefix + "/list",
                    createUrl: prefix + "/add",
                    updateUrl: prefix + "/edit/{id}",
                    removeUrl: prefix + "/remove",
                    exportUrl: prefix + "/export",
                    modalName: "销售出库",
                    columns: [
                        {
                            field: 'id',
                            title: '编号',
                            visible: false
                        },
                        {
                            title: '发货通知单',
                            formatter: function (value, row, index) {
                                var actions = [];
                                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" ' +
                                    'href="javascript:void(0)" onclick="DanJuShow(' + row.id + ')">' +
                                    '<i class="fa fa-edit"></i>出库通知单</a> ');
                                return actions.join('');
                            }
                        },
                        {
                            field: 'zhixing',
                            title: '是否已出库'
                        },
                        {
                            field: 'chukuDanhao',
                            title: '出库单号'
                        },
                        {
                            field: 'fahuoDanhao',
                            title: '发货单号'
                        },
                        {
                            field: 'chukuDate',
                            title: '销售日期'
                        },
                        {
                            field: 'xiangmuName',
                            title: '项目名称'
                        },
                        {
                            field: 'xiangmuMen',
                            title: '业务员'
                        },
                        {
                            field: 'fahuoRen',
                            title: '发货人'
                        },
                        {
                            field: 'peitao1',
                            title: '配套类型'
                        },
                        {
                            field: 'goodNameMen1',
                            title: '门扇名称'
                        },
                        {
                            field: 'kaiXiang1',
                            title: '开向'
                        },
                        {
                            field: 'men1Shuliang',
                            title: '门扇数量'
                        },
                        {
                            field: 'kuangShuliang',
                            title: '门框数量'
                        },
                        {
                            field: 'shuliang1',
                            title: '防火锁数'
                        },
                        {
                            field: 'shuliang2',
                            title: '闭门器数'
                        },
                        {
                            field: 'shuliang3',
                            title: '拉爆盖数'
                        },
                        {
                            field: 'beizhu1',
                            title: '门扇备注'
                        },
                        {
                            field: 'zhonjine',
                            title: '销售金额'
                        }]
                };
                $.table.init(options);
            })
        }

        function selectSomeOne(id) {
            $.ajax({
                type:"POST",
                datatype: "string",
                url: "/xiaoshouchuku/chukuTest/selectAll/"+id,
                data: {},
                async:false,//是否是异步请求
                success: function (result) {
                    if (result.code===0) {
                        $.modal.open('整单详细信息','/xiaoshouchuku/chukuTest/selectAll',1000,800)
                    }else {
                        alert("单据详细未找到")
                    }
                    // document.getElementById("msg2saoma").value = ""
                    // document.getElementById("msg2saoma").focus()
                },
                error : function() {
                    alert("后台响应出现问题");
                }
            });
        }

        function DanJuShow(id) {
            $.ajax({
                type:"get",
                datatype: "string",
                url: "/xiaoshouchuku/chukuTest/showOne/"+id,
                data: {},
                async:false,//是否是异步请求
                success: function (result) {
                    if (result.code === 0) {
                        $.modal.open('出库通知单','/xiaoshouchuku/chukuTest/showOne',1000,800)
                    }else {
                        alert("单据详细未找到")
                    }
                    // document.getElementById("msg2saoma").value = ""
                    // document.getElementById("msg2saoma").focus()
                },
                error : function() {
                    alert("后台响应出现问题");
                }
            });
        }

        function f() {
            $.modal.parentTab('扫码录入','/xiaoshouchuku/chukuTest/selectAll',true)
        }

        // var id = setInterval(function () {
        //     var erroemsg = window.sessionStorage.getItem("errorMsg")
        //     if (erroemsg !== null && erroemsg !== ""){
        //         alert(erroemsg)
        //         clearInterval(id)
        //     }
        // },10000)
    </script>
</body>
</html>